#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/15 14:57
# @Author: 刘航
# @Email: xxx@gmail.com
# @File：login_page.py

"""
登录界面
"""
from config.config import HOST
from pages.cus_mag_pages.base_page import BasePage
from selenium.webdriver.common.by import By

class LoginPage(BasePage):
    """类属性"""
    url = "http://{}/crm".format(HOST)
    username_locator = (By.NAME,"name")
    password_locator = (By.NAME,"password")
    btn_locator = (By.CLASS_NAME,"btn-primary")

    def username_input(self,username):
        """用户名方法"""
        self.driver.find_element(*self.username_locator).send_keys(username)


    def password_input(self,password):
        """密码方法"""
        self.driver.find_element(*self.password_locator).send_keys(password)


    def login_sure(self):
        """登录按钮方法"""
        self.driver.find_element(*self.btn_locator).click()

    def login(self,username,password):
        self.username_input(username) #输入用户名
        self.password_input(password) #输入密码
        self.login_sure() #点击确定

